"""
扫码贷用信模块
"""
import unittest
import requests
import time
from cookie import login

header = {'cookie': login.Logins()}
nowtime = time.strftime('%Y%m%d%H%M%S')
one_time = time.strftime('%Y-%m-%d %H%M%S')
two_time = time.strftime('%Y-%m-%d')
noweppid = '0000000001118286438'
nowidno = '130101198712040017'


class Rxd_Smd_yx(unittest.TestCase):

    def setUp(self):
        self.base_url = 'http://plsadmpre.cnsuning.com/plsadm/loan/test/confirmCommitLoan.do'

    def tearDown(self):
        print(self.result)

    def test_smyx(self):
        paydata = {'paySerialNo': nowtime, 'payOrderId': nowtime, 'eppAccountId': noweppid, 'applyTime': one_time,
                   'applyAmount': '600', 'idNo': nowidno, 'signCode': two_time, 'repayWay': 'R9925', 'loanTerm': '6',
                   'personLoanId': '21966406', 'projectCode': '204', 'partnerNo': '10', 'intfNo': 'Q009',
                   'quotaType': '02', 'termType': '02'}
        r = requests.post(url=self.base_url, data=paydata, headers=header)
        self.result = r.json()
        if len(str(self.result)) > 50:
            result = eval(self.result['result'])
            self.assertEqual(result["status"], '01')
        else:
            self.assertEqual(self.result["result"], '成功')


if __name__ == '__main__':
    unittest.main()
